package com.ssfGame.puremvc.view.application
{
	import com.ssfGame.puremvc.StaticConst;
	import com.ssfGame.puremvc.view.vc.LoadLayerVC;
	
	import flash.display.DisplayObject;
	import flash.display.DisplayObjectContainer;
	import flash.display.Sprite;
	
	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.patterns.mediator.Mediator;
	
	/**
	 * 
	 * @author chery
	 */
	public class LoadLayerMediator extends Mediator
	{
		/**
		 * 
		 * @default 
		 */
		public static const NAME:String="LoadLayerMediator"
		/**
		 * 
		 * @param mediatorName
		 * @param viewComponent
		 */
		public function LoadLayerMediator(mediatorName:String=null, viewComponent:Object=null)
		{
			super(mediatorName, viewComponent);
		}
		override public function listNotificationInterests():Array{
			return [
				StaticConst.N_M_LOAD_LAYER_ADD,
				StaticConst.N_M_LOAD_LAYER_DEL
			]
		}
		override public function handleNotification(notification:INotification):void{
			switch (notification.getName()){
				case StaticConst.N_M_LOAD_LAYER_ADD:
					var vc_add:DisplayObject=notification.getBody() as DisplayObject
					if(vc_add==null){
						return;
					}
					if(!loadLayerVC.contains(vc_add)){
						loadLayerVC.addChild(vc_add);
					}
					break
				case StaticConst.N_M_LOAD_LAYER_DEL:
					
					var vc_del:DisplayObject=notification.getBody() as DisplayObject
					if(vc_del==null){
						return;
					}
				
					if(loadLayerVC.contains(vc_del)){
						loadLayerVC.removeChild(vc_del);
					}
					break
			}
		}
		
		
		private function get loadLayerVC():LoadLayerVC{
			return viewComponent as LoadLayerVC
		}
	}
}